package myWork;

public class Twosp {
    public static void main(String[] args) {
        int [] arr = {1,2,3,4,5,6,7,8,9,10};
        int number = 12;
        int index = Two(arr,number);
        System.out.println(index);
    }

    private static int Two(int[] arr, int number) {
        int max = arr.length-1;
        int min = 0;
        while (max>=min){
            int mid = (max+min)/2;
            if (arr[mid]<number){
                min = mid + 1;
            }else if (arr[max]>number){
                max = mid - 1;
            }else{
                return mid;
            }
        }
        return -1;
    }
}
